/**
 * 建立MongoDB数据库连接
 */
const mongoose = require('mongoose');
const URL = 'mongodb://192.168.100.201:27017/users';
mongoose.connect(URL);

// connect 返回一个状态待定的连接
var db = mongoose.connection;

db.on('error', err => {
  console.log('error');
});

db.once('open', function() {
  console.log("Successful connection to " + URL);
});

module.exports = mongoose;